package com.carple.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.carple.dao.LoveBoardDao;
import com.carple.dao.MemberDao;
import com.carple.dto.Member;

/**
 * Servlet implementation class LoginServlet
 */
@WebServlet("/loveboard/delete.action")
public class LoveBoardDeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		//1. 요청 데이터 읽기(글 번호)
		String boardNo = request.getParameter("boardno");
		System.out.println("inDao"+boardNo);
		if(boardNo == null || boardNo.length() == 0){
			response.sendRedirect("list.action");
			return;
		}
		
		//2. 데이터 처리(DB에서 조회)
		LoveBoardDao dao = new LoveBoardDao();
		dao.deleteBoard(Integer.parseInt(boardNo));
		
		//3. 목록으로 이동
		 response.sendRedirect("list.action");
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		doGet(request, response);
	}

}
